package projet.camping.usecasesimpl;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import projet.camping.dao.UserDao;
import projet.camping.domaine.User;
import projet.camping.exception.ArgumentInvalideException;
import projet.camping.usecases.GestionUser;
import projet.camping.util.Util;

@Stateless
public class GestionUserimpl implements GestionUser{

	@EJB UserDao userDao;
	
	

	@Override
	public User creerUser(String pseudo) throws ArgumentInvalideException {
		Util.checkString(pseudo);
		User u = userDao.rechercheUser(pseudo);
			if(u!=null)
				return u;
			u= new User(pseudo);
			userDao.enregistrer(u);
			return u;
	}


	
	
}
